float3 LightDir0;
float3 LightDir1;
float3 LightDir2;
float4x4 WorldViewProjection;
float4x4 World;
float3 CameraPosition;
float4 Booleans01;	
float4x3 Bones[60];

// Structs
struct VS_INPUT
{
    float4 position				: POSITION;
	float3 normal				: NORMAL;
	float2 textureCoords		: TEXCOORD0;
	int4 indices : BLENDINDICES0;
	float4 weights : BLENDWEIGHT0;
	float3 tangent				: TANGENT;
};

struct VS_OUTPUT
{
    float4 position				: POSITION;
	float2 textureCoords		: TEXCOORD0;
	float3 normalW				: TEXCOORD1;
	float3 tangentW				: TEXCOORD2;
	float3 binormalW			: TEXCOORD3;
	float3x3 halfLights			: TEXCOORD4;
};


// Shaders
VS_OUTPUT main(VS_INPUT In)
{
    VS_OUTPUT Out = (VS_OUTPUT)0;
	float4x3 bone0 = Bones[In.indices[0]] * In.weights[0];
	float4x3 bone1 = Bones[In.indices[1]] * In.weights[1];
	float4x3 bone2 = Bones[In.indices[2]] * In.weights[2];
	float4x3 bone3 = Bones[In.indices[3]] * In.weights[3];
	
	float3x3 skinWorld = ((float3x3)bone0 + (float3x3)bone1 + (float3x3)bone2 + (float3x3)bone3) * (float3x3)World;
	
	float3x3 skinWVP = ((float3x3)bone0 + (float3x3)bone1 + (float3x3)bone2 + (float3x3)bone3) * (float3x3)WorldViewProjection;
	float3 pos = 0;
    pos += mul(In.position, bone0);
    pos += mul(In.position, bone1);
    pos += mul(In.position, bone2);
    pos += mul(In.position, bone3);
	In.position.xyz = pos;
	Out.position = mul(In.position, WorldViewProjection);
	
	Out.normalW = mul(In.normal, skinWorld);
	Out.tangentW = mul(In.tangent, skinWorld);
	Out.binormalW = cross(Out.normalW, Out.tangentW);
	if(Booleans01.w>0.5)
		Out.binormalW = -Out.binormalW;
	
	Out.textureCoords = In.textureCoords;
	float3 positionW = mul(In.position, World).xyz;
	//Out.normalW = mul(In.normal, (float3x3)World);
	//applyBonesTangent(4,In);
	

	float3 eyeDir = normalize(CameraPosition - positionW);
	Out.halfLights[0] = 0.5 * (-LightDir0 + eyeDir);
	Out.halfLights[1] = 0.5 * (-LightDir1 + eyeDir);
	Out.halfLights[2] = 0.5 * (-LightDir2 + eyeDir);

	

    return Out;
}
